Program Slicing Using Weakest Preconditions

نویسندگان

  • Joseph J. Comuzzi
  • Johnson M. Hart
چکیده

Program slices have long been used as an aid to program understanding, especially in maintenance activities. Most slicing methods involve data and control flow analysis to determine what statements might affect a set of variables. Here, we develop a more precise slicing concept, called p-slices, defined using Dijkstra’s weakest precondition (wp), to determine which statements will affect a specified predicate. Weakest preconditions are already known to be an effective technique for program understanding and analysis, and this paper unifies wp analysis and slicing and simplifies existing slicing algorithms. Slicing rules for assignment, conditional, and repetition statements are developed. The authors are currently using these techniques in their work with software maintenance teams and are incorporating p-slice computation into a program analysis tool. Introduction The concept of slicing a program in order to aid understanding, maintenance, and resuse goes back to Weiser [13, 14]. The basic idea is to create a reduced program consisting of only those statements that affect a given variable or set of variables. In this way, the software engineer can concentrate on the relevant parts of the code. Livadas and Croll [11] review the case for slicing and the related techniques of dicing and ripple analysis, showing the benefits for code understanding, code simplification, reuse, maintenance, and other tasks. [11] then proceeds to present an improved slicing algorithm based on program and system dependence graphs. The present authors have become convinced of the value of logical code analysis (LCA) in all aspects of software maintenance [8, 9] as well as in earlier phases of the software life-cycle. LCA applies the theory of weakest precondition program semantics (wp) as developed by Dijkstra [4] and extended in such works as [3, 5, 7]. wp theory was originally developed for program synthesis and proofs of correctness, but, as mentioned above, we have found that the wp theory, or what we call LCA, is extremely effective for program understanding and maintenance. There are a number of reasons for this, one of which is that LCA efficiently represents control and data flow and precisely captures the relevant information that the slicing algorithms capture with dependence graphs. The wp-based definition of a slice (called a p-slice or predicate slice) gives a desirable alternative to the classical slice concept, and, in addition, p-slices can be computed quickly, assuming reasonable constraints. The paper starts by giving a background in slicing and weakest precondition semantics. Following that, we define the p-slice and show why it is a valuable alternative to Weiser’s classical slice definition. Next, we develop some p-slice theorems for alternation and repetition statements and proceed to use the theorems to compute p-slices in some examples. We conclude with some comments on directions for future work. Program Slicing Using Weakest Preconditions Joseph J. Comuzzi and Johnson M. Hart

برای دانلود متن کامل این مقاله و بیش از 32 میلیون مقاله دیگر ابتدا ثبت نام کنید

ثبت نام

اگر عضو سایت هستید لطفا وارد حساب کاربری خود شوید

منابع مشابه

Commutativity of quantum weakest preconditions

The notion of quantum weakest precondition was introduced by D’Hondt and P. Panangaden (Mathematical Structures in Computer Science 16(2006)429-451), and they presented a representation of weakest precondition of a quantum program in the operatorsum form. In this letter, we give an intrinsic characterization of the weakest precondition of a quantum program given in a systemenvironment model. Fu...

متن کامل

Weakest Preconditions for High-Level Programs (Long Version)

In proof theory, a standard method for showing the correctness of a program w.r.t. given preand postconditions is to construct a weakest precondition and to show that the precondition implies the weakest precondition. In this paper, graph programs in the sense of Habel and Plump 2001 are extended to programs over high-level rules with application conditions, a formal definition of weakest preco...

متن کامل

Weakest Preconditions for High-Level Programs

In proof theory, a standard method for showing the correctness of a program w.r.t. given preand postconditions is to construct a weakest precondition and to show that the precondition implies the weakest precondition. In this paper, graph programs in the sense of Habel and Plump 2001 are extended to programs over high-level rules with application conditions, a formal definition of weakest preco...

متن کامل

Simple characterizations for commutativity of quantum weakest preconditions

In a recent letter by Ying et al. [Inf. Process. Lett. 104 (2007) 152-158], it showed some sufficient conditions for commutativity of quantum weakest preconditions. This paper provides some simple characterizations for the commutativity of quantum weakest preconditions, i.e., Theorem 3, Theorem 4 and Proposition 5 in what follows. We also show that to characterize the commutativity of quantum w...

متن کامل

Formula Slicing: Inductive Invariants from Preconditions

We propose a “formula slicing” method for finding inductive invariants. It is based on the observation that many loops in the program affect only a small part of the memory, and many invariants which were valid before a loop are still valid after. Given a precondition of the loop, obtained from the preceding program fragment, we weaken it until it becomes inductive. The weakening procedure is g...

متن کامل

ذخیره در منابع من


  با ذخیره ی این منبع در منابع من، دسترسی به آن را برای استفاده های بعدی آسان تر کنید

برای دانلود متن کامل این مقاله و بیش از 32 میلیون مقاله دیگر ابتدا ثبت نام کنید

ثبت نام

اگر عضو سایت هستید لطفا وارد حساب کاربری خود شوید

عنوان ژورنال:

دوره   شماره 

صفحات  -

تاریخ انتشار 1996